// 添加用户
let form = layui.form;
let layer = layui.layer;

form.verify({
    yanzheng: function(value, item) {
        if (value !== $('#psw').val()) {
            return '两次密码不一致'
        }
    },
    pass: [/^[\S]{6,12}$/, '密码必须6到12位，且不能出现空格'],
});

$('form').on('submit', function(e) {
    e.preventDefault();
    let val = $(this).serialize();
    // console.log(val);
    $.ajax({
        url: '/admin/users',
        type: 'POST',
        data: val,
        success: function(res) {
            layer.msg(res.message);
            location.href = './user.html'
        }
    })
});